package me.zhengjie.inter.service.impl;

import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.business.domain.AdlZhsq;
import me.zhengjie.business.domain.Order;
import me.zhengjie.business.domain.Zhsq;
import me.zhengjie.business.domain.sup.Gsgl;
import me.zhengjie.business.repository.AdlZhsqRepository;
import me.zhengjie.business.repository.GsglRepository;
import me.zhengjie.business.repository.OrderRepository;
import me.zhengjie.business.repository.ZhsqRepository;
import me.zhengjie.business.service.dto.AdlZhsqDto;
import me.zhengjie.business.service.mapstruct.AdlZhsqMapper;
import me.zhengjie.domain.LocalStorage;
import me.zhengjie.inter.service.MpAdlZhsqService;
import me.zhengjie.inter.service.MpPjService;
import me.zhengjie.repository.LocalStorageRepository;
import me.zhengjie.utils.SecurityUtils;
import org.springframework.stereotype.Service;

/**
 * @description 服务接口
 * @author xiahongbo
 * @date 2022-08-28
 **/
@Slf4j
@Service
@RequiredArgsConstructor
public class MpPjServiceImpl implements MpPjService {


    private final OrderRepository orderRepository;
    private final ZhsqRepository zhsqRepository;
    private final GsglRepository gsglRepository;


    @Override
    public JSONObject queryInfo(String orderId) {
        Order order = orderRepository.findById(orderId).orElseGet(Order::new);
        Long zhid = order.getBisOrderZhid();
        Zhsq zhsq = zhsqRepository.findById(zhid).orElseGet(Zhsq::new);
        String sbgsId = zhsq.getBisSbgsId();
        Gsgl gsgl = gsglRepository.findById(sbgsId).orElseGet(Gsgl::new);
        JSONObject jsonObject = new JSONObject();

        jsonObject.put("orderId", order.getBisOrderId());
        jsonObject.put("hlyId", order.getBisOrderHlyId());
        jsonObject.put("hlyName", order.getBisOrderHlyName());
        jsonObject.put("zhId", order.getBisOrderZhid());
        jsonObject.put("snryName", zhsq.getBisZhsqSnryXm());
        jsonObject.put("snryId", zhsq.getBisZhsqSnryId());
        jsonObject.put("hljgId", zhsq.getHljg().getBisGsglId());
        jsonObject.put("hljgName", zhsq.getHljg().getBisGsglQymc());
        jsonObject.put("sbgsId", gsgl.getBisGsglId());
        jsonObject.put("sbgsName", gsgl.getBisGsglQymc());
        return jsonObject;
    }
}
